{% load bootstrapped_goodies_tags %}
<fieldset class="card" id="fieldset-{% if stacked_prefix %}{{ stacked_prefix }}-{% endif %}{{ forloop.counter }}" style="background:transparent">
    {% if fieldset.name %}
        <div class="card-header">
            {% if 'collapse' in fieldset.classes %}
                <a data-bs-toggle="collapse" data-bs-target="#fieldset-{% if stacked_prefix %}{{ stacked_prefix }}-{% endif %}{{ forloop.counter }} .fields">
                    {{ fieldset.name }}
                    &nbsp;<span class="btn btn-sm btn-secondary"><span class="glyphicon glyphglyphicon glyphicon-resize-full"></i></span>
                </a>
            {% else %}
                <strong>{{ fieldset.name }}</strong>
            {% endif %}
        </div>
    {% else %}
        <div class="card-header">
            <strong>{{ opts.verbose_name_plural|capfirst }}</strong>
        </div>
    {% endif %}
    <div class="card-body">
        {% if fieldset.description %}
            <div class="nb-description">{{ fieldset.description|safe }}</div>
        {% endif %}
        {% for line in fieldset %}
            <div class="row">
                <div class="control-group {% if line.fields|length_is:'1' and line.errors %} error{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not line.has_visible_field %} d-none{% endif %}{% endfor %}">
                    {% for field in line %}
                        <div class="col-lg-12 mb-10 d-flex justify-content-center{% if not line.fields|length_is:'1' %} field-box{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} d-none{% endif %}{% endif %}">
                            <div class="col-form-label col-lg-3">
                                {{ field.label_tag }}
                            </div>
                            {% if field.is_checkbox %}
                                <div class="controls col-lg-9">
                                    <div class="form-check">
                                        {% dab_field_rendering field.field %} {% if field.field.help_text %}<br><span class="form-text">{{ field.field.help_text|safe }}</span>{% endif %}
                                    </div>
                                </div>
                            {% else %}
                                <div class="controls col-lg-9">
                                    {% if field.is_readonly %}
                                        <p>{{ field.contents }}</p>
                                    {% else %}
                                        {% dab_field_rendering field.field %}
                                    {% endif %}
                                    {% if not field.is_readonly and field.errors %}<span class="text-danger">{{ field.errors|striptags }}</span>{% endif %}
                                    {% if field.field.help_text %}
                                        <span class="form-text">{{ field.field.help_text|safe }}</span>
                                    {% endif %}
                                </div>
                            {% endif %}
                        </div>
                    {% endfor %}
                </div>
            </div>
        {% endfor %}
    </div>
</fieldset>
